﻿@using TamoCRM.Domain.UserRole
@{
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";

    // User
    var users = ViewBag.Users;
    ((List<UserInfo>)users).RemoveAll(c => c.GroupId == 0);
    ((List<UserInfo>)users).Insert(0, new UserInfo { UserID = 0, FullName = "Tất cả" });
    var lstUsers = new SelectList(users, "UserID", "FullName");

    var lstCampains = new SelectList(ViewBag.Campains, "Id", "Name");
    var lstAppointmentCallTypes = new SelectList(ViewBag.AppointmentCallTypes, "Id", "Name");
}
<style type="text/css">
    .acceptl1-table thead tr {
        height: 47px;
    }

    .acceptl1-table tbody tr td {
        vertical-align: middle !important;
    }
</style>
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed');
        } catch (e) { }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="/Home">Trang chủ</a>
        </li>

        <li>
            <a href="javascript:void(0);">Contact</a>
        </li>
        <li class="active">Danh sách Contact có hẹn</li>
    </ul>
</div>

<div class="page-content">
    <div class="page-header">
        <h1>Danh sách Contact có hẹn						
        </h1>
    </div>
    <!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <div id="spiner"></div>
        </div>
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            @using (Ajax.BeginForm("FilterContactAppointment", "ContactFilter", new AjaxOptions { HttpMethod = "POST" }, new { enctype = "multipart/form-data", @class = "form-horizontal", role = "form", id = "frmAcceptContactL1" }))
            {
                @Html.AntiForgeryToken()
                <div class="row" style="margin-left: 30px;">
                    <div class="col-xs-1" style="width: 5%;">
                        CTV
                    </div>
                    <div class="col-xs-3">
                        <div class="clearfix">
                            @Html.DropDownList("UserId", lstUsers, new { @style = "width: 100%" })
                        </div>
                    </div>
                    <div class="col-xs-1">
                        Trạng thái
                    </div>
                    <div class="col-xs-3">
                        <div class="clearfix">
                            @Html.DropDownList("AppointmentCallType", lstAppointmentCallTypes, new { @style = "width: 100%" })
                        </div>
                    </div>
                    <div class="col-xs-1">
                        Campain
                    </div>
                    <div class="col-xs-3">
                        <div class="clearfix">
                            @Html.DropDownList("Campain", lstCampains, new { @style = "width: 100%" })
                        </div>
                    </div>
                </div>
                <div class="space-6"></div>
                <div class="row" style="margin-left: 30px;">
                    <div class="col-xs-1" style="width: 5%;">
                        &nbsp;
                    </div>
                    <div class="col-xs-3">
                        &nbsp;
                    </div>
                    <div class="col-xs-1" style="width: 8.5%;">
                        Từ ngày
                    </div>
                    <div class="col-xs-3">
                        <div class="clearfix">
                            @Html.TextBox("Name", DateTime.Now.ToString("dd/MM/yyyy"), new { @style = "width: 100%" })
                        </div>
                    </div>
                    <div class="col-xs-1" style="width: 8.5%;">
                        Đến ngày
                    </div>
                    <div class="col-xs-3">
                        <div class="clearfix">
                            @Html.TextBox("Name", DateTime.Now.ToString("dd/MM/yyyy"), new { @style = "width: 100%" })
                        </div>
                    </div>
                </div>
                <hr />
                <div class="space-2"></div>
                <button id="btnFilterContact" class="btn-primary" style="margin-bottom: 10px; float: right;">Lọc Contact</button>
                <div class="clearfix"></div>
                <div class="space-4"></div>
                <div class="row">
                    <div class="col-xs-12">
                        <table id="grid-table"></table>
                        <div id="grid-pager"></div>
                    </div>
                </div>
            }
            <!-- PAGE CONTENT ENDS -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</div>

<script type="text/javascript">
    var url = 'admin/api/contact/filterreuse?branchId={0}';
    var grid_selector = "#grid-table";
    var heades = ['Id', 'Họ và tên', 'Level', 'Ngày', 'Sáng/Chiều', 'Giờ', 'Thời gian gọi hẹn', 'Trạng thái', 'Tổng số cuộc gọi', 'Campain', 'CTV'];
    var model = [
        { name: 'CallHistoryId', index: 'CallHistoryId', editable: false, sorttype: 'string', editoptions: { disabled: true }, width: '0px' },
        {
            name: 'ContactName', index: 'ContactName', editable: false, width: '100px', align: 'center', formatter: "dynamicLink",
            formatoptions: {
                cellValue: function (cellValue, rowId, rowData, options) {
                    return '<div style="color:#810c15;margin:5px;"><a href="/admin/contactlevelinfo/edit/' + rowData.ContactId + '">' + rowData.ContactName + '</a></div>';
                }
            }
        },
        { name: 'LevelId', index: 'LevelId', editable: false, width: '40px', sorttype: 'string', align: 'center', formatter: levelFomatter },
        { name: 'RecallTime', index: 'RecallTime', editable: false, width: '60px', align: 'center', formatter: 'date', formatoptions: { srcformat: 'Y-m-dTH:i:s', newformat: 'd/m/Y' } },
        { name: 'RecallTimeAmPm', index: 'RecallTime', editable: false, width: '70px', align: 'center', formatter: stringFormatter },
        { name: 'RecallTimeTime', index: 'RecallTime', editable: false, width: '40px', align: 'center', formatter: 'date', formatoptions: { srcformat: 'Y-m-dTH:i:s', newformat: 'H:i' } },
        { name: 'CallCenterInfo', index: 'CallCenterInfo', editable: false, width: '150px', sorttype: 'string', align: 'left' },
        { name: 'CallTime', index: 'CallTime', editable: false, sorttype: 'string', width: '60px', formatter: 'date', formatoptions: { srcformat: 'Y-m-dTH:i:s', newformat: 'd/m/Y H:i' } },
        { name: 'StatusCareId', index: 'StatusCareId', editable: false, width: '120px', formatter: statusCareFomatter },
        { name: 'StatusCareId', index: 'StatusCareId', editable: false, width: '120px', formatter: statusCareFomatter },
        { name: 'StatusCareId', index: 'StatusCareId', editable: false, width: '120px', formatter: statusCareFomatter }
    ];

    $(document).ready(function () {
        var branchId = 0;
        setupGridWithoutEdit("#grid-table", "#grid-pager", url.format(branchId), "admin/api/contact/edit", "Id", "Danh sách Contact", heades, model);
        $(grid_selector).jqGrid("setGroupHeaders", {
            useColSpanStyle: true,
            groupHeaders: [
                { startColumnName: "RecallTime", numberOfColumns: 3, titleText: '<table style="width:100%;border-spacing:0px;"><tr><td style="text-align:center;height:40px;"><b>Lịch gọi</b></td></tr></table>' }
            ]
        });
    });
</script>

